package com.example.fw;

import java.util.ArrayList;
import java.util.List;

import org.netbeans.jemmy.operators.JButtonOperator;
import org.netbeans.jemmy.operators.JDialogOperator;
import org.netbeans.jemmy.operators.JTextFieldOperator;
import org.netbeans.jemmy.operators.JTreeOperator;


public class FolderHelper extends HelpersBase {

	public FolderHelper (ApplicationManager manager) {	
		super(manager);
	}

	public Folders getFolders() {
		List<String> list = new ArrayList<String>();
		JTreeOperator tree = new JTreeOperator(mainFrame);
		Object[] children =  tree.getChildren(tree.getRoot());
		for (Object child : children) {
			list.add(child.toString());
		}
		return new Folders(list);
	}

	public String createFolder(String name) {
		manager.getMenuerHelper().pushCreateFolder();
		JDialogOperator dialog = new JDialogOperator(mainFrame);
		new JTextFieldOperator(dialog).setText(name);
		new JButtonOperator(dialog, "OK").push();
		return waitMessageDiaog("Warning", 3000);
	}

	public void deleteFolder(int index) {
		JTreeOperator tree = new JTreeOperator(mainFrame);
		tree.selectRow(index);
		manager.getMenuerHelper().pushDelete();
		JDialogOperator dialog = new JDialogOperator(mainFrame);
		new JButtonOperator(dialog, "Yes").push();		
	}	

} 
